Skip to content

fix(voice): ignore the voice key while processing and trim silence from dictated pieces - #821

Merged
LeanBitLab merged 1 commit into
mainfrom
fix/voice-key-and-trailing-piece
Nov 15, 2026
Merged

LeanBitLab merged 1 commit into
mainfrom
fix/voice-key-and-trailing-piece

Conversation

@LeanBitLab

Copy link
Copy Markdown
Owner

Summary of Changes

Two voice dictation fixes found while testing "Transcribe while speaking" on a device.

Motivation & Context

  1. Tapping the voice key during "Processing" started a new session. startVoice() cancels the previous session first, so any text still being recognized was dropped.
  2. A stray word (for example "No.") was added after a dictation. The last piece included the whole silence timeout, and a single noisy frame counted as speech, so Whisper was given near-silent audio and invented text for it.

Changes Made

  • VoiceInputManager.voiceKeyActionFor decides what the voice key does: stop while recording, ignore while the final text is being recognized, start otherwise. LatinIME uses it. The cancel button on the strip still cancels on purpose.
  • Pieces track real speech time and the end of the last speech frame. The silence after the last speech is cut off (500 ms padding, at least 1 s kept, whole 16 bit samples), and a piece with less than 300 ms of speech is dropped instead of sent to Whisper. This applies to pieces cut at a pause and to the last piece.
  • VoicePiecewiseTest covers the trim and the key rule.

Verification & Testing

  • helium314.keyboard.latin.voice.* unit tests pass
  • Builds and installs on a device
  • Not exercised with live audio: tap the voice key during Processing and check the text still appears; dictate a short phrase and check no extra word follows

Guidelines Checklist

  • This PR addresses a single focused concern.
  • Does not add unnecessary dependencies or binary blobs.
  • No em dashes used in comments, descriptions, or documentation.

…om dictated pieces

Pressing the voice key during Processing started a new session, which
cancelled the pending recognition and dropped its text. Ignore it in that
state; the cancel button on the strip still does it on purpose.

In transcribe while speaking, the last piece included the whole silence
timeout and a single noisy frame counted as speech, so Whisper invented
trailing words. Cut the silence after the last speech (keeping 0.5 s of
padding, at least 1 s) and drop pieces with under 300 ms of speech.
@LeanBitLab
LeanBitLab merged commit e7d606f into main Nov 15, 2026
1 check passed
@LeanBitLab
LeanBitLab deleted the fix/voice-key-and-trailing-piece branch November 15, 2026 08:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant